from redis import *

if __name__ == "__main__":
    try:
        # 创建StrictRedis对象，与redis服务器建⽴连接
        sr = StrictRedis(
            host="192.168.142.129",
            port=6379,
            db=0,
        )
        # 添加键name，值为itheima
        result = sr.set("name", "哈哈哈，链接成功了")
        # 输出响应结果，如果添加成功则返回True，否则返回False
        print(result)
        str = sr.get("name")
        print("哈哈哈，链接成功了~~~：", str)
    except Exception as e:
        print(e)
